import { API } from '../../api/model';
import ACTION_TYPE from '../constant/action-types';

export function requestAdd(api) {
  return {
    type: ACTION_TYPE.REQUSET_ADD_API_PROVIDER,
    payload: api,
  };
}

export function add(api) {
  return {
    type: ACTION_TYPE.ADD_API_PROVIDER,
    payload: api,
  };
}

export function requestRemove(api) {
  return {
    type: ACTION_TYPE.REQUEST_REMOVE_API_PROVIDER,
    payload: api,
  };
}

export function remove(api) {
  return {
    type: ACTION_TYPE.REMOVE_API_PROVIDER,
    payload: api,
  };
}

export function requestUpdate(id, api) {
  return {
    type: ACTION_TYPE.REQUEST_UPDATE_API_PROVIDER,
    payload: {
      id,
      api,
    },
  };
}

export function update(id, api) {
  return {
    type: ACTION_TYPE.UPDATE_API_PROVIDER,
    payload: {
      id,
      api,
    },
  };
}

export function setApiList(list) {
  return {
    type: ACTION_TYPE.SET_API_PROVIDER_LIST,
    payload: {
      list: API.createList(list),
    },
  };
}
